package com.zyt.comm.plugins.mybatisplus.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zyt.comm.plugins.mybatisplus.service.IZytService;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;
import java.util.Set;

/**
 * 封装
 * @param <M>
 * @param <T>
 * @author magl
 */
public class ZytServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements IZytService<T> {

    @Resource
    public RedisTemplate objectRedisTemplate;

    @Override
    public void resetRedisCache(String key) {
        String keys = "*" + key + "*";
        Set<String> keySet = objectRedisTemplate.keys(keys);
        if (CollectionUtil.isNotEmpty(keySet)) {
            objectRedisTemplate.delete(keySet);
        }
    }
}
